<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRolesTable extends Migration
{
    /**
     * Run the migrations.
     * 角色表
     * @return void
     */
    public function up()
    {
        Schema::create('roles', function (Blueprint $table) {
            $table->increments('id');
            // $table->integer('mark')->unsigned()->comment('编码')->nullable();
            $table->string('name')->comment('角色名称');
            $table->text('description')->comment('角色描述')->nullable();
            // $table->integer('type')->comment('角色类型')->default(0);
            // $table->foreign('type')->references('id')->on('role_categories');
            // $table->integer('attr')->unsigned()->comment('角色属性')->default(0);
            // $table->boolean('default')->comment('系统预置')->default(0);
            $table->integer('organization_id')->unsigned()->comment('组织ID')->nullable();
            $table->foreign('organization_id')->references('id')->on('organizations');
            $table->string('creator')->comment('创建人')->default('admin');
            $table->string('disable')->comment('禁用人')->default('admin');
            $table->timestamp('disable_time')->comment('禁用时间')->useCurrent();
            $table->boolean('disable_state')->comment('禁用状态 0反禁用-启用 1禁用')->default(0);
            $table->softDeletes();
            $table->timestamps();
            $table->unique(['name','deleted_at']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('roles');
    }
}
